package com.ruoyi.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.domain.ParkingCardSpec;
import com.ruoyi.service.IParkingCardSpecService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 停车卡配置Controller
 * 
 * @author dongdong
 * @date 2025-09-09
 */
@RestController
@RequestMapping("/parking/parkingCardSpec")
public class ParkingCardSpecController extends BaseController
{
    @Autowired
    private IParkingCardSpecService parkingCardSpecService;

    /**
     * 查询停车卡配置列表
     */
    @PreAuthorize("@ss.hasPermi('parking:parkingCardSpec:list')")
    @GetMapping("/list")
    public TableDataInfo list(ParkingCardSpec parkingCardSpec)
    {
        startPage();
        List<ParkingCardSpec> list = parkingCardSpecService.selectParkingCardSpecList(parkingCardSpec);
        return getDataTable(list);
    }

    /**
     * 导出停车卡配置列表
     */
    @PreAuthorize("@ss.hasPermi('parking:parkingCardSpec:export')")
    @Log(title = "停车卡配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ParkingCardSpec parkingCardSpec)
    {
        List<ParkingCardSpec> list = parkingCardSpecService.selectParkingCardSpecList(parkingCardSpec);
        ExcelUtil<ParkingCardSpec> util = new ExcelUtil<ParkingCardSpec>(ParkingCardSpec.class);
        util.exportExcel(response, list, "停车卡配置数据");
    }

    /**
     * 获取停车卡配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('parking:parkingCardSpec:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(parkingCardSpecService.selectParkingCardSpecById(id));
    }

    /**
     * 新增停车卡配置
     */
    @PreAuthorize("@ss.hasPermi('parking:parkingCardSpec:add')")
    @Log(title = "停车卡配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ParkingCardSpec parkingCardSpec)
    {
        return toAjax(parkingCardSpecService.insertParkingCardSpec(parkingCardSpec));
    }

    /**
     * 修改停车卡配置
     */
    @PreAuthorize("@ss.hasPermi('parking:parkingCardSpec:edit')")
    @Log(title = "停车卡配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ParkingCardSpec parkingCardSpec)
    {
        return toAjax(parkingCardSpecService.updateParkingCardSpec(parkingCardSpec));
    }

    /**
     * 删除停车卡配置
     */
    @PreAuthorize("@ss.hasPermi('parking:parkingCardSpec:remove')")
    @Log(title = "停车卡配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(parkingCardSpecService.deleteParkingCardSpecByIds(ids));
    }
}
